package com.heima.comment.controller.v1;

import com.heima.comment.service.CommentService;
import com.heima.model.comment.pojos.CommentLikeDto;
import com.heima.model.comment.pojos.CommentLoadDto;
import com.heima.model.comment.pojos.CommentSaveDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    /**
     * 发评论
     * @param dto
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody CommentSaveDto dto){
        return commentService.saveComment(dto);
    }

    /**
     * 点赞评论
     * @param dto
     * @return
     */
    @PostMapping("/like")
    public ResponseResult like(@RequestBody CommentLikeDto dto){
        return commentService.like(dto);
    }
    /**
     * 加载评论列表
     * @param dto
     * @return
     */
    @PostMapping("/load")
    public ResponseResult commentList(@RequestBody CommentLoadDto dto){
        return commentService.loadComment(dto);
    }
}
